package com.moli.iov.admin.utils;

import com.moli.iov.base.enums.DictTypeTag;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class DictFactory {

    private Map<String,Map<String,String>> map;

    public DictFactory(Map<String,Map<String,String>> map){
        this.map = map;
    }

    public String getValue(DictTypeTag type, String code){
        Map<String, String> temp = map.get(type.getType());
        if(temp!=null){
            String value = temp.get(code);
            if(value==null){
                log.error("[通过字典获取数据为null][type:{}][code:{}]",type,code);
            }else{
                return value;
            }
        }else{
            log.error("[通过字典类型获取数据为null][type:{}]",type);
        }
        return Contant.NULL;
    }

    public String getValue(DictTypeTag type, Integer code){
        if(code!=null){
            return this.getValue(type,code.toString());
        }
        return Contant.NULL;

    }

}
